package github.flandre.examplemod.client.gui;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import github.flandre.examplemod.examplemod;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.util.ResourceLocation;

public class ExampleHUD extends AbstractGui {
    public static final ResourceLocation TEXTURES =
            new ResourceLocation(examplemod.MODID,"textures/gui/example_gui.png");
    private final int width;
    private final int hegith;
    private final Minecraft minecraft;
    private MatrixStack matrixStack;

    public ExampleHUD(MatrixStack matrixStack) {
        this.width = Minecraft.getInstance().getMainWindow().getWidth();
        this.hegith = Minecraft.getInstance().getMainWindow().getHeight();
        this.minecraft = Minecraft.getInstance();
        this.matrixStack = matrixStack;
    }

    public void setMatrixStack(MatrixStack matrixStack) {
        this.matrixStack = matrixStack;
    }

    //渲染图像方法
    public void render(float power)
    {
        //清空画笔
        RenderSystem.color4f(1.0f,1.0f,1.0f,1.0f);
        //绑定贴图
        this.minecraft.getTextureManager().bindTexture(TEXTURES);
        //渲染贴图
        blit(matrixStack,0,0,0,9,80,40);
        blit(matrixStack,0,15,power<4?0:9,0,9,9);
        //渲染文字 字体 文字
        drawCenteredString(matrixStack,minecraft.fontRenderer,"POWER:" + power,
                40,15,0xffffff);

    }
}
